<?php
if(!defined('IN_IBEIKE')) {
	exit('Access Denied');
}

class table_common_smiley extends common_table
{
	public function __construct() {

		$this->_table = 'common_smiley';
		$this->_pk    = 'id';

		parent::__construct();
	}
	public function fetch_all_cache() {
		return DB::fetch_all("SELECT * FROM %t ORDER BY LENGTH(code) DESC", array($this->_table));
	}
	public function fetch_all_by_id($id){
		if(!empty($id)&&$id){
			return DB::fetch_all('SELECT * FROM %t WHERE id=%s',array($this->_table,$id));//返回数组包含各个字段的值
		}
		return false;
	}
	public function put_smiley_to_array(){
		return DB::fetch_all("select * from %t",array($this->_table));//已返回一个二维数组
		
	}
	public function put_bbcode_add_to_array(){//
		$result=DB::fetch_all("select bbcode,code from %t",array($this->_table));//已返回一个二维数组
		$smiley=array();
		foreach ($result as $arg){
			$smiley[$arg['bbcode']]=$arg['code'];
		}
		return $smiley;
	
	}
	public function check_smiley_bbcode($imgname){
		if(!empty($imgname)){
			$result=DB::fetch_first("select * from %t where bbcode=%s",array($this->_table,$imgname));
			if(DB::num_rows($result)==0){
				return 0;
			}else{
				return $result;
			}
		}else{
			return false;
		}
	}
	

	
}
?>